'use strict'

const http = require('http')

if (process.argv.indexOf('--strong') > 0) {
  ;['SIGINT', 'SIGTERM', 'SIGABRT'].forEach(x => {
    process.on(x, sig => {
      console.log(process.pid, '接收到信号', sig, ', 不会退出')
    })
  })
}

http.createServer((req, res) => {
  req.on('data', chunk=> {})

  req.on('end', () => {
    res.end(`success ${req.url}`)
  })

}).listen(3456, '0.0.0.0', () => {
  console.log(process.pid, 'server listen 3456', process.argv)
})

process.on('message', (msg) => {
  console.log('web app', msg)
})

if (process.send) {
  process.send({pid: process.pid})
}

process.rss = Buffer.alloc(parseInt(100_000_000 * Math.random()) + 45_000_000, 'x')
console.log(process.memoryUsage())
